summaryrefslogtreecommitdiff
path: root/addons/l10n_ch
diff options
context:
space:
mode:
authorLaurent Smet <las@odoo.com>2019-05-29 13:35:09 +0000
committerqdp-odoo <qdp@odoo.com>2019-06-28 11:52:55 +0000
commitbeaa30a3d1843de43a45f419bfbc1bfa7613a920 (patch)
tree00e62f6861eb15b3735fe032b849fd3e6150868c /addons/l10n_ch
parent0bd61b5245e475825fdeb33fb7b9ddb4f378c657 (diff)
[IMP/REF] accounting-pocalypse yeaaahh
This commit merges the following models * account.invoice and account.move * account.invoice.line and account.move.line * account.voucher and account.move * account.voucher.line and account.move.line It was the opportunity for a big cleanup of the code, so it also restructures the whole account module, its different models/fields, the tests etc. for a better world and a better code readability. ==== Rationale ==== The rationale of this huge change is that we want journal entries / invoices to be easily edited, and changes reflected in the other model. It's a HUGE feature and very strategic for the fiduciary companies. For example, changing the account of a journal entry needs to be automatically reflected on the related invoice. The same reasoning applies to sale/purchase vouchers. ==== Changes made in features ===== When creating an invoice, you are now creating a journal entry directly. --> The object account.invoice no longer exists. In the same fashion when creating an invoice line, you're now adding journal items directly in the journal entry representing the invoice. If this invoice line has some tax, it may create additional journal items as well. --> The models account.invoice.line & account.invoice.tax no longer exist Identically, when creating a sale/purchase receipt with its lines, you are now creating a journal entry directly and there's no more usability difference between encoding a receipt or an invoice. --> The object account.voucher no longer exists. --> The object account.voucher.line no longer exists. --> The whole account_voucher module no longer exists. Positive side-effects coming from these changes are * draft invoices/bills/sale or purchase receipts now create a draft accounting entry. Validate these objects now simply post its journal entry. That means that draft invoices/bills/sale or purchase receipt can straightforwardly be included in reporting or budgets. * opening a journal entry in form view will now always open the correct view: if it's a sale/purchase journal entry we will have a customer invoice/vendor bill view or a sale/purchase receipt view, whatever the menu we're coming from. * code & business logic simplification. It is also condensed in a single place instead of being partially duplicated on invoices, vouchers and journal entries. There should be no feature loss, except the one allowing to group multiple journal items together based on the same product during the invoice validation. ==== Changes made in models ===== * account.invoice: model removed. Instead, now use account.move with following mapping field (account.invoice) field (account.move) ----------------------- -------------------- name invoice_payment_ref number name reference ref comment narration user_id invoice_user_id amount_ total_company_signed amount_total_signed residual amount_residual state state + invoice_payment_state /!\ selection changed date_invoice invoice_date date_due invoice_date_due sent invoice_sent origin invoice_origin payment_term_id invoice_payment_term_id partner_bank_id invoice_partner_bank_id incoterm_id invoice_incoterm_id vendor_bill_id invoice_vendor_bill_id source_email invoice_source_email vendor_display_name invoice_vendor_display_name invoice_icon invoice_vendor_icon cash_rounding_id invoice_cash_rounding_id sequence_number_next invoice_sequence_number_next sequence_number_next_prefix invoice_sequence_number_next_prefix 'invoices' subset of account.move can be accessed by using the selection field 'type' or one of the many helpers like is_invoice() * account.move: now has a valid state 'cancel' that has to be excluded from all business logic * account.move: field 'amount' renamed into 'amount_total' * account.move: field 'reverse_entry_id' renamed into 'reversed_entry_id' * account.move.line: now has a field 'display_type' that has to be excluded from all business logic, in order to support invoice layouting * account.invoice.line: model removed. Instead, now use account.move.line with following mapping field (account.invoice.line) field (account.move.line) ---------------------------- ------------------------- invoice_id move_id uom_id product_uom_id invoice_line_tax_ids tax_ids account_analytic_id analytic_account_id 'invoice lines' subset of all account.move.line from a journal entry can be accessed by using the boolean field 'exclude_from_invoice_tab' * account.invoice.tax: model removed. Instead, now use account.move.line with following mapping field (account.invoice.tax) field (account.move.line) --------------------------- ------------------------- invoice_id move_id account_analytic_id analytic_account_id amount price_unit base tax_base_amount 'tax lines' subset of all account.move.line from a journal entry can be accessed by using the relational field 'tax_line_id' * account.invoice.confirm: model removed. Instead, now use the 'post()' function of account.move * account.invoice.refund: model removed. Instead, now use account.move.reversal to reverse the entries with the same options as we had for invoices * account.voucher: model removed. Instead, now use account.move of type in ['out_receipt', 'in_receipt] * account.voucher.line: model removed. Instead, now use account.move.line ==== Changes made in functions ==== * on account.move, method _run_post_draft_to_post() renamed into _autopost_draft_entries() * on account.move, method action_account_invoice_payment() renamed into action_invoice_register_payment() * on account.move, method action_invoice_reconcile_to_check() renamed into action_open_matching_suspense_moves() * on account.move, method _get_domain_edition_mode_available() renamed into _get_domain_matching_supsense_moves() * on account.move, method _get_intrastat_country_id() renamed into _get_invoice_intrastat_country_id() * on account.move.line, method _get_domain_for_edition_mode() renamed into _get_suspense_moves_domain() * in account.bank.statement, contextual key 'edition_mode' renamed into 'suspense_moves_mode' Was task 1917430
Diffstat (limited to 'addons/l10n_ch')
-rw-r--r--addons/l10n_ch/models/account_invoice.py46
-rw-r--r--addons/l10n_ch/models/mail_template.py2
-rw-r--r--addons/l10n_ch/report/isr_report.xml20
-rw-r--r--addons/l10n_ch/report/swissqr_report.xml26
-rw-r--r--addons/l10n_ch/tests/test_l10n_ch_isr.py37
-rw-r--r--addons/l10n_ch/views/account_invoice_view.xml36
6 files changed, 82 insertions, 85 deletions
diff --git a/addons/l10n_ch/models/account_invoice.py b/addons/l10n_ch/models/account_invoice.py
index 01c8b747329..1238d18bdd8 100644
--- a/addons/l10n_ch/models/account_invoice.py
+++ b/addons/l10n_ch/models/account_invoice.py
@@ -12,8 +12,8 @@ from odoo.tools.misc import mod10r
l10n_ch_ISR_NUMBER_LENGTH = 27
l10n_ch_ISR_NUMBER_ISSUER_LENGTH = 12
-class AccountInvoice(models.Model):
- _inherit = 'account.invoice'
+class AccountMove(models.Model):
+ _inherit = 'account.move'
l10n_ch_isr_postal = fields.Char(compute='_compute_l10n_ch_isr_postal', help='The postal reference identifying the bank managing this ISR.')
l10n_ch_isr_postal_formatted = fields.Char(compute='_compute_l10n_ch_isr_postal', help="Postal reference of the bank, formated with '-' and without the padding zeros, to generate ISR report.")
@@ -28,7 +28,7 @@ class AccountInvoice(models.Model):
l10n_ch_isr_sent = fields.Boolean(defaut=False, help="Boolean value telling whether or not the ISR corresponding to this invoice has already been printed or sent by mail.")
l10n_ch_currency_name = fields.Char(related='currency_id.name', readonly=False, string="Currency Name", help="The name of this invoice's currency") #This field is used in the "invisible" condition field of the 'Print ISR' button.
- @api.depends('partner_bank_id.bank_id.l10n_ch_postal_eur', 'partner_bank_id.bank_id.l10n_ch_postal_chf')
+ @api.depends('invoice_partner_bank_id.bank_id.l10n_ch_postal_eur', 'invoice_partner_bank_id.bank_id.l10n_ch_postal_chf')
def _compute_l10n_ch_isr_postal(self):
""" Computes the postal reference identifying the bank managing this ISR and formats it accordingly"""
def _format_isr_postal(isr_postal):
@@ -44,12 +44,11 @@ class AccountInvoice(models.Model):
return isr_postal[:2] + isr_postal[2:-1].rjust(6, '0') + isr_postal[-1:]
for record in self:
- if record.partner_bank_id and record.partner_bank_id.bank_id:
- isr_postal = False
+ if record.invoice_partner_bank_id and record.invoice_partner_bank_id.bank_id:
if record.currency_id.name == 'EUR':
- isr_postal = record.partner_bank_id.bank_id.l10n_ch_postal_eur
+ isr_postal = record.invoice_partner_bank_id.bank_id.l10n_ch_postal_eur
elif record.currency_id.name == 'CHF':
- isr_postal = record.partner_bank_id.bank_id.l10n_ch_postal_chf
+ isr_postal = record.invoice_partner_bank_id.bank_id.l10n_ch_postal_chf
else:
#we don't format if in another currency as EUR or CHF
continue
@@ -58,7 +57,7 @@ class AccountInvoice(models.Model):
record.l10n_ch_isr_postal = _format_isr_postal_scanline(isr_postal)
record.l10n_ch_isr_postal_formatted = _format_isr_postal(isr_postal)
- @api.depends('number', 'partner_bank_id.l10n_ch_postal')
+ @api.depends('name', 'invoice_partner_bank_id.l10n_ch_postal')
def _compute_l10n_ch_isr_number(self):
""" The ISR reference number is 27 characters long. The first 12 of them
contain the postal account number of this ISR's issuer, removing the zeros
@@ -80,10 +79,10 @@ class AccountInvoice(models.Model):
return res
for record in self:
- if record.number and record.partner_bank_id and record.partner_bank_id.l10n_ch_postal:
- invoice_issuer_ref = re.sub('^0*', '', record.partner_bank_id.l10n_ch_postal)
+ if record.name and record.invoice_partner_bank_id and record.invoice_partner_bank_id.l10n_ch_postal:
+ invoice_issuer_ref = re.sub('^0*', '', record.invoice_partner_bank_id.l10n_ch_postal)
invoice_issuer_ref = invoice_issuer_ref.ljust(l10n_ch_ISR_NUMBER_ISSUER_LENGTH, '0')
- invoice_ref = re.sub('[^\d]', '', record.number)
+ invoice_ref = re.sub('[^\d]', '', record.name)
#We only keep the last digits of the sequence number if it is too long
invoice_ref = invoice_ref[-l10n_ch_ISR_NUMBER_ISSUER_LENGTH:]
internal_ref = invoice_ref.zfill(l10n_ch_ISR_NUMBER_LENGTH - l10n_ch_ISR_NUMBER_ISSUER_LENGTH - 1) # -1 for mod10r check character
@@ -91,7 +90,11 @@ class AccountInvoice(models.Model):
record.l10n_ch_isr_number = mod10r(invoice_issuer_ref + internal_ref)
record.l10n_ch_isr_number_spaced = _space_isr_number(record.l10n_ch_isr_number)
- @api.depends('currency_id.name', 'amount_total', 'partner_bank_id.bank_id', 'number', 'partner_bank_id.l10n_ch_postal', 'partner_bank_id.bank_id.l10n_ch_postal_eur', 'partner_bank_id.bank_id.l10n_ch_postal_chf')
+ @api.depends(
+ 'currency_id.name', 'amount_total', 'name',
+ 'invoice_partner_bank_id.l10n_ch_postal',
+ 'invoice_partner_bank_id.bank_id.l10n_ch_postal_eur',
+ 'invoice_partner_bank_id.bank_id.l10n_ch_postal_chf')
def _compute_l10n_ch_isr_optical_line(self):
""" The optical reading line of the ISR looks like this :
left>isr_ref+ bank_ref>
@@ -125,15 +128,18 @@ class AccountInvoice(models.Model):
#Final assembly (the space after the '+' is no typo, it stands in the specs.)
record.l10n_ch_isr_optical_line = left + '>' + record.l10n_ch_isr_number + '+ ' + record.l10n_ch_isr_postal + '>'
- @api.depends('type', 'number', 'partner_bank_id.l10n_ch_postal', 'partner_bank_id.bank_id', 'currency_id.name', 'partner_bank_id.bank_id.l10n_ch_postal_eur', 'partner_bank_id.bank_id.l10n_ch_postal_chf')
+ @api.depends(
+ 'type', 'name', 'currency_id.name',
+ 'invoice_partner_bank_id.l10n_ch_postal',
+ 'invoice_partner_bank_id.bank_id.l10n_ch_postal_eur',
+ 'invoice_partner_bank_id.bank_id.l10n_ch_postal_chf')
def _compute_l10n_ch_isr_valid(self):
"""Returns True if all the data required to generate the ISR are present"""
for record in self:
record.l10n_ch_isr_valid = record.type == 'out_invoice' and\
- record.number and \
+ record.name and \
record.l10n_ch_isr_postal and \
- record.partner_bank_id and \
- record.partner_bank_id.l10n_ch_postal and \
+ record.invoice_partner_bank_id.l10n_ch_postal and \
record.l10n_ch_currency_name in ['EUR', 'CHF']
def split_total_amount(self):
@@ -169,10 +175,10 @@ class AccountInvoice(models.Model):
- associate this bank with a postal reference for the currency used in this invoice\n
- fill the 'bank account' field of the invoice with the postal to be used to receive the related payment. A default account will be automatically set for all invoices created after you defined a postal account for your company."""))
+ @api.multi
def action_invoice_sent(self):
- """ Overridden. Triggered by the 'send by mail' button.
- """
- rslt = super(AccountInvoice, self).action_invoice_sent()
+ # OVERRIDE
+ rslt = super(AccountMove, self).action_invoice_sent()
if self.l10n_ch_isr_valid:
rslt['context']['l10n_ch_mark_isr_as_sent'] = True
@@ -184,4 +190,4 @@ class AccountInvoice(models.Model):
def message_post(self, **kwargs):
if self.env.context.get('l10n_ch_mark_isr_as_sent'):
self.filtered(lambda inv: not inv.l10n_ch_isr_sent).write({'l10n_ch_isr_sent': True})
- return super(AccountInvoice, self.with_context(mail_post_autofollow=True)).message_post(**kwargs)
+ return super(AccountMove, self.with_context(mail_post_autofollow=True)).message_post(**kwargs)
diff --git a/addons/l10n_ch/models/mail_template.py b/addons/l10n_ch/models/mail_template.py
index 7ec29d4d508..30918bd4b78 100644
--- a/addons/l10n_ch/models/mail_template.py
+++ b/addons/l10n_ch/models/mail_template.py
@@ -28,7 +28,7 @@ class MailTemplate(models.Model):
for res_id in res_ids:
related_model = self.env[self.model_id.model].browse(res_id)
- if related_model._name == 'account.invoice' and related_model.l10n_ch_isr_valid:
+ if related_model._name == 'account.move' and related_model.l10n_ch_isr_valid:
#We add an attachment containing the ISR
template = res_ids_to_templates[res_id]
report_name = 'ISR-' + self._render_template(template.report_name, template.model, res_id) + '.pdf'
diff --git a/addons/l10n_ch/report/isr_report.xml b/addons/l10n_ch/report/isr_report.xml
index 26d843789d8..bf25cf171e8 100644
--- a/addons/l10n_ch/report/isr_report.xml
+++ b/addons/l10n_ch/report/isr_report.xml
@@ -17,15 +17,15 @@
<!--Report containing an ISR corrresponding to an invoice.-->
<report id="l10n_ch_isr_report"
- model="account.invoice"
+ model="account.move"
report_type="qweb-pdf"
string="ISR"
name="l10n_ch.isr_report_main"
file="l10n_ch.isr_report_main"
attachment_use="True"
- attachment="'ISR-' + object.number + '.pdf'"
+ attachment="'ISR-' + object.name + '.pdf'"
menu="False"
- print_report_name="'ISR-%s' % object.number"
+ print_report_name="'ISR-%s' % object.name"
paperformat="paperformat_euro_no_margin"/>
<!--No additional condition in report name on invoice state or type as this
report is only available to be printed for out invoices after
@@ -48,7 +48,7 @@
<!-- since the body content take the whole page we need a way to add margin
back on content outside the ISR so it does not overlap with the header -->
<div id="content_outside_isr">
- <h1>ISR for invoice <t t-esc="invoice.number"/></h1>
+ <h1>ISR for invoice <t t-esc="invoice.name"/></h1>
</div>
<div id="isr" t-att-class="'isr-print-bank' if print_bank else None">
@@ -62,9 +62,9 @@
<t t-if="print_bank">
<div id="voucher-for-bank">
<p t-if="not invoice.company_id.l10n_ch_isr_preprinted_bank">
- <t t-esc="invoice.partner_bank_id.bank_id.name"/><br />
- <t t-esc="invoice.partner_bank_id.bank_id.zip"/>
- <t t-esc="invoice.partner_bank_id.bank_id.city"/>
+ <t t-esc="invoice.invoice_partner_bank_id.bank_id.name"/><br />
+ <t t-esc="invoice.invoice_partner_bank_id.bank_id.zip"/>
+ <t t-esc="invoice.invoice_partner_bank_id.bank_id.city"/>
</p>
</div>
<!--Zugunsten von/En faveur de/A favore di-->
@@ -103,9 +103,9 @@
<t t-if="print_bank">
<div id="slip-for-bank">
<p t-if="not invoice.company_id.l10n_ch_isr_preprinted_bank">
- <t t-esc="invoice.partner_bank_id.bank_id.name"/><br />
- <t t-esc="invoice.partner_bank_id.bank_id.zip"/>
- <t t-esc="invoice.partner_bank_id.bank_id.city"/>
+ <t t-esc="invoice.invoice_partner_bank_id.bank_id.name"/><br />
+ <t t-esc="invoice.invoice_partner_bank_id.bank_id.zip"/>
+ <t t-esc="invoice.invoice_partner_bank_id.bank_id.city"/>
</p>
</div>
<!--Zugunsten von/En faveur de/A favore di-->
diff --git a/addons/l10n_ch/report/swissqr_report.xml b/addons/l10n_ch/report/swissqr_report.xml
index 46ab9a8db26..8199ef8b9bf 100644
--- a/addons/l10n_ch/report/swissqr_report.xml
+++ b/addons/l10n_ch/report/swissqr_report.xml
@@ -5,7 +5,7 @@
<xpath expr="//div[@id='qrcode']" position="after">
<link type="text/css" rel="stylesheet" href="/l10n_ch/static/src/scss/report_swissqr.css"/>
<div class="swissqr_content" t-if="o.display_swiss_qr_code()">
- <div class="swissqr_body" t-if="o.partner_bank_id.validate_swiss_code_arguments(o.partner_bank_id.currency_id, o.partner_id) and ((o.currency_id.name == 'EUR') or (o.currency_id.name == 'CHF'))">
+ <div class="swissqr_body" t-if="o.invoice_partner_bank_id.validate_swiss_code_arguments(o.invoice_partner_bank_id.currency_id, o.partner_id) and ((o.currency_id.name == 'EUR') or (o.currency_id.name == 'CHF'))">
<div id="title_zone" class="swissqr_column_left title_zone">
<span class="swissqr_text title title_zone">QR-bill payment part</span><br/>
</div>
@@ -15,14 +15,14 @@
<span class="swissqr_text content">Credit transfer</span>
</div>
- <img class="swissqr" t-att-src="o.partner_bank_id.build_swiss_code_url(o.residual, o.currency_id.name, o.date_due, o.partner_id, 'QRR',
- (o.partner_bank_id.bank_id.l10n_ch_postal_eur) if (o.partner_bank_id.currency_id.name == 'EUR') else o.partner_bank_id.bank_id.l10n_ch_postal_chf,
- (o.reference) if (o.reference) else o.number)"/>
+ <img class="swissqr" t-att-src="o.invoice_partner_bank_id.build_swiss_code_url(o.amount_residual, o.currency_id.name, o.invoice_date_due, o.partner_id, 'QRR',
+ (o.invoice_partner_bank_id.bank_id.l10n_ch_postal_eur) if (o.invoice_partner_bank_id.currency_id.name == 'EUR') else o.invoice_partner_bank_id.bank_id.l10n_ch_postal_chf,
+ (o.ref) if (o.ref) else o.name)"/>
<img class="ch_cross" src="/l10n_ch/static/src/img/CH-Cross_7mm.png"/>
<div id="indications_zone" class="swissqr_column_right indication_zone">
<span class="swissqr_text title">Account</span><br/>
- <span class="swissqr_text content" t-field="o.partner_bank_id.acc_number"/><br/>
+ <span class="swissqr_text content" t-field="o.invoice_partner_bank_id.acc_number"/><br/>
<span class="swissqr_text title">Creditor</span><br/>
<span class="swissqr_text content" t-field="o.company_id.name"/><br/>
@@ -32,15 +32,15 @@
<span class="swissqr_text content" t-field="o.company_id.city"/><br/>
<span class="swissqr_text title">Reference number</span><br/>
- <t t-if="o.partner_bank_id.currency_id.name == 'EUR'">
- <span class="swissqr_text content" t-field="o.partner_bank_id.bank_id.l10n_ch_postal_eur"/><br/>
+ <t t-if="o.invoice_partner_bank_id.currency_id.name == 'EUR'">
+ <span class="swissqr_text content" t-field="o.invoice_partner_bank_id.bank_id.l10n_ch_postal_eur"/><br/>
</t>
- <t t-if="o.partner_bank_id.currency_id.name == 'CHF'">
- <span class="swissqr_text content" t-field="o.partner_bank_id.bank_id.l10n_ch_postal_chf"/><br/>
+ <t t-if="o.invoice_partner_bank_id.currency_id.name == 'CHF'">
+ <span class="swissqr_text content" t-field="o.invoice_partner_bank_id.bank_id.l10n_ch_postal_chf"/><br/>
</t>
<span class="swissqr_text title">Additional information</span><br/>
- <span class="swissqr_text content" t-field="o.reference"/><br/>
+ <span class="swissqr_text content" t-field="o.ref"/><br/>
<span class="swissqr_text title">Debtor</span><br/>
<span class="swissqr_text content" t-field="o.partner_id.name"/><br/>
@@ -51,7 +51,7 @@
<span class="swissqr_text content" t-field="o.partner_id.city"/><br/>
<span class="swissqr_text title">Due date</span><br/>
- <span class="swissqr_text content" t-field="o.date_due"/><br/>
+ <span class="swissqr_text content" t-field="o.invoice_date_due"/><br/>
</div>
<div id="amount_zone" class="swissqr_column_left amount_zone">
@@ -61,11 +61,11 @@
<div class="amount_zone amount">
<span class="swissqr_text title">Amount</span><br/>
- <t t-set="formated_amount" t-value="('%.2f' % (o.residual)).split(' ')[0].replace(',',' ')"/>
+ <t t-set="formated_amount" t-value="('%.2f' % (o.amount_residual)).split(' ')[0].replace(',',' ')"/>
<span class="swissqr_text content" t-esc="formated_amount"/>
</div>
</div>
- <div class="swissqr_body" t-if="(o.partner_bank_id.validate_swiss_code_arguments(o.partner_bank_id.currency_id, o.partner_id) == False) and ((o.currency_id.name == 'EUR') or (o.currency_id.name == 'CHF'))">
+ <div class="swissqr_body" t-if="(o.invoice_partner_bank_id.validate_swiss_code_arguments(o.invoice_partner_bank_id.currency_id, o.partner_id) == False) and ((o.currency_id.name == 'EUR') or (o.currency_id.name == 'CHF'))">
<div class="swissqr_column_left procedure_zone">
<span>Some pieces of this information are not set correctly to display the Swiss QR Code.<br/>
-Bank > CHF ISR reference<br/>
diff --git a/addons/l10n_ch/tests/test_l10n_ch_isr.py b/addons/l10n_ch/tests/test_l10n_ch_isr.py
index 2ff830342e2..2a089dccd1d 100644
--- a/addons/l10n_ch/tests/test_l10n_ch_isr.py
+++ b/addons/l10n_ch/tests/test_l10n_ch_isr.py
@@ -13,38 +13,27 @@ class ISRTest(AccountingTestCase):
def create_invoice(self, currency_to_use='base.CHF'):
""" Generates a test invoice """
- account_receivable = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_receivable').id)], limit=1)
- currency = self.env.ref(currency_to_use)
- partner_agrolait = self.env.ref("base.res_partner_2")
- product = self.env.ref("product.product_product_4")
- account_revenue = self.env['account.account'].search([('user_type_id', '=', self.env.ref('account.data_account_type_revenue').id)], limit=1)
-
- invoice = self.env['account.invoice'].create({
- 'partner_id': partner_agrolait.id,
- 'currency_id': currency.id,
- 'name': 'invoice to client',
- 'account_id': account_receivable.id,
+ invoice = self.env['account.move'].with_context(default_type='out_invoice').create({
'type': 'out_invoice',
- 'date_invoice': time.strftime('%Y') + '-12-22',
+ 'partner_id': self.env.ref("base.res_partner_2").id,
+ 'currency_id': self.env.ref(currency_to_use).id,
+ 'invoice_date': time.strftime('%Y') + '-12-22',
+ 'invoice_line_ids': [
+ (0, 0, {
+ 'product_id': self.env.ref("product.product_product_4").id,
+ 'quantity': 1,
+ 'price_unit': 42,
+ }),
+ ],
})
-
- self.env['account.invoice.line'].create({
- 'product_id': product.id,
- 'quantity': 1,
- 'price_unit': 42,
- 'invoice_id': invoice.id,
- 'name': 'something',
- 'account_id': account_revenue.id,
- })
-
- invoice.action_invoice_open()
+ invoice.post()
return invoice
def create_account(self, number):
""" Generates a test res.partner.bank. """
return self.env['res.partner.bank'].create({
- 'acc_number': number
+ 'acc_number': number,
})
def print_isr(self, invoice):
diff --git a/addons/l10n_ch/views/account_invoice_view.xml b/addons/l10n_ch/views/account_invoice_view.xml
index e550670de85..52421816d1d 100644
--- a/addons/l10n_ch/views/account_invoice_view.xml
+++ b/addons/l10n_ch/views/account_invoice_view.xml
@@ -3,14 +3,10 @@
<data>
<record id="isr_invoice_form" model="ir.ui.view">
<field name="name">l10n_ch.account.invoice.form</field>
- <field name="model">account.invoice</field>
- <field name="inherit_id" ref="account.invoice_form"/>
+ <field name="model">account.move</field>
+ <field name="inherit_id" ref="account.view_move_form"/>
<field name="arch" type="xml">
- <xpath expr="//field[@name='partner_bank_id']" position="attributes">
- <attribute name="invisible">0</attribute>
- </xpath>
-
- <xpath expr="//field[@name='sent']" position="after">
+ <xpath expr="//field[@name='invoice_sent']" position="after">
<field name="l10n_ch_isr_sent" invisible="1"/>
<field name="l10n_ch_currency_name" invisible="1"/>
</xpath>
@@ -20,9 +16,12 @@
name="isr_print"
string="Print ISR"
type="object"
- attrs="{'invisible':['|', ('l10n_ch_isr_sent', '=', True),
- '|', ('state', '!=', 'open'),
- ('l10n_ch_currency_name', 'not in', ['EUR', 'CHF'])]}"
+ attrs="{'invisible':['|', '|', '|', '|',
+ ('type', 'not in', ('out_invoice', 'out_refund')),
+ ('l10n_ch_isr_sent', '=', True),
+ ('state', '!=', 'posted'),
+ ('invoice_payment_state', '!=', 'not_paid'),
+ ('l10n_ch_currency_name', 'not in', ['EUR', 'CHF'])]}"
class="oe_highlight"
groups="base.group_user"
/>
@@ -33,9 +32,12 @@
name="isr_print"
string="Print ISR"
type="object"
- attrs="{'invisible':['|', ('l10n_ch_isr_sent', '=', False),
- '|', ('state', '!=', 'open'),
- ('l10n_ch_currency_name', 'not in', ['EUR', 'CHF'])]}"
+ attrs="{'invisible':['|', '|', '|', '|',
+ ('type', 'not in', ('out_invoice', 'out_refund')),
+ ('l10n_ch_isr_sent', '=', False),
+ ('state', '!=', 'posted'),
+ ('invoice_payment_state', '!=', 'not_paid'),
+ ('l10n_ch_currency_name', 'not in', ['EUR', 'CHF'])]}"
groups="base.group_user"
/>
</xpath>
@@ -44,7 +46,7 @@
<record id="isr_invoice_search_view" model="ir.ui.view">
<field name="name">l10n_ch.invoice.select</field>
- <field name="model">account.invoice</field>
+ <field name="model">account.move</field>
<field name="inherit_id" ref="account.view_account_invoice_filter"/>
<field name="mode">primary</field>
<field name="arch" type="xml">
@@ -56,10 +58,10 @@
<!--Overridden action (and primary child view), so the filter are only
available for customer invoices-->
- <record id="account.action_invoice_tree1" model="ir.actions.act_window">
+ <record id="account.action_move_out_invoice_type" model="ir.actions.act_window">
<field name="name">Customer Invoices</field>
- <field name="res_model">account.invoice</field>
+ <field name="res_model">account.move</field>
<field name="search_view_id" ref="isr_invoice_search_view"/>
</record>
</data>
-</odoo> \ No newline at end of file
+</odoo>