[IMP] l10n_hu, l10n_sa, account: delivery date + hu brush up

In this pr, we have improved the l10n_hu localization by adding a Tax rounding
(global) by default.

Also, a lot of localization will need a delivery date on invoices. We added a
field in account that can be overridden if needed. In this pr, we did an
override on l10n_sa and l10n_hu.

When creating a sale order and that the effective date is fill, we take this
value for the delivery date.

The delivery date field will always be displayed in the other info tab, and if
there is a delivery data, the field is also display in the header of the form
view. Exception for l10n_sa and l10n_hu where the delivery date is always
present.

Also for l10n_sa company there was a problem with the vat number, it was not in
the right format.

Task-id: 3191530
Part-of: odoo/odoo#116643
This commit is contained in:
det
2023-07-10 15:32:07 +02:00
committed by Maximilien (malb)
parent a3b0e9a3c4
commit a5801a12b5
13 changed files with 79 additions and 33 deletions
+6
View File
@@ -66,6 +66,7 @@ class AccountChartTemplate(models.AbstractModel):
'invoice_user_id': 'base.user_demo',
'invoice_payment_term_id': 'account.account_payment_term_end_following_month',
'invoice_date': time.strftime('%Y-%m-01'),
'delivery_date': time.strftime('%Y-%m-01'),
'invoice_line_ids': [
Command.create({'product_id': 'product.consu_delivery_02', 'quantity': 5}),
Command.create({'product_id': 'product.consu_delivery_03', 'quantity': 5}),
@@ -76,6 +77,7 @@ class AccountChartTemplate(models.AbstractModel):
'partner_id': 'base.res_partner_2',
'invoice_user_id': False,
'invoice_date': time.strftime('%Y-%m-08'),
'delivery_date': time.strftime('%Y-%m-08'),
'invoice_line_ids': [
Command.create({'product_id': 'product.consu_delivery_03', 'quantity': 5}),
Command.create({'product_id': 'product.consu_delivery_01', 'quantity': 20}),
@@ -86,6 +88,7 @@ class AccountChartTemplate(models.AbstractModel):
'partner_id': 'base.res_partner_2',
'invoice_user_id': False,
'invoice_date': time.strftime('%Y-%m-08'),
'delivery_date': time.strftime('%Y-%m-08'),
'invoice_line_ids': [
Command.create({'product_id': 'product.consu_delivery_01', 'quantity': 5}),
Command.create({'product_id': 'product.consu_delivery_03', 'quantity': 5}),
@@ -97,6 +100,7 @@ class AccountChartTemplate(models.AbstractModel):
'invoice_user_id': 'base.user_demo',
'invoice_payment_term_id': 'account.account_payment_term_immediate',
'invoice_date': (fields.Date.today() + timedelta(days=-15)).strftime('%Y-%m-%d'),
'delivery_date': (fields.Date.today() + timedelta(days=-15)).strftime('%Y-%m-%d'),
'invoice_line_ids': [
Command.create({'product_id': 'product.consu_delivery_02', 'quantity': 5}),
Command.create({'product_id': 'product.consu_delivery_03', 'quantity': 5}),
@@ -108,6 +112,7 @@ class AccountChartTemplate(models.AbstractModel):
'invoice_user_id': 'base.user_demo',
'invoice_payment_term_id': 'account.account_payment_term_end_following_month',
'invoice_date': time.strftime('%Y-%m-01'),
'delivery_date': time.strftime('%Y-%m-01'),
'invoice_line_ids': [
Command.create({'product_id': 'product.product_delivery_01', 'price_unit': 10.0, 'quantity': 1}),
Command.create({'product_id': 'product.product_order_01', 'price_unit': 4.0, 'quantity': 5}),
@@ -123,6 +128,7 @@ class AccountChartTemplate(models.AbstractModel):
'partner_id': 'base.res_partner_12',
'invoice_user_id': False,
'invoice_date': fifteen_months_ago.strftime("%Y-%m-17"),
'delivery_date': fifteen_months_ago.strftime("%Y-%m-17"),
'invoice_line_ids': [
Command.create({'name': 'Redeem Reference Number: PO02529', 'quantity': 1, 'price_unit': 541.10,
'tax_ids': self.env.company.account_purchase_tax_id.ids}),
+17
View File
@@ -286,6 +286,15 @@ class AccountMove(models.Model):
index=True,
copy=False,
)
delivery_date = fields.Date(
string='Delivery Date',
copy=False,
readonly=True,
store=True,
compute='_compute_delivery_date',
states={'draft': [('readonly', False)]},
)
show_delivery_date = fields.Boolean(compute='_compute_show_delivery_date')
invoice_payment_term_id = fields.Many2one(
comodel_name='account.payment.term',
string='Payment Terms',
@@ -842,6 +851,14 @@ class AccountMove(models.Model):
default=False,
) or move.invoice_date_due or today
def _compute_delivery_date(self):
pass
@api.depends('delivery_date')
def _compute_show_delivery_date(self):
for move in self:
move.show_delivery_date = move.delivery_date and move.is_sale_document()
@api.depends('journal_id', 'statement_line_id')
def _compute_currency_id(self):
for invoice in self:
+3 -1
View File
@@ -758,6 +758,7 @@
<field name="hide_post_button" invisible="1"/>
<field name="duplicated_ref_ids" invisible="1"/>
<field name="quick_encoding_vals" invisible="1"/>
<field name="show_delivery_date" invisible="1"/>
<div class="oe_title">
<span class="o_form_label"><field name="move_type" attrs="{'invisible': [('move_type', '=', 'entry')]}" readonly="1" nolabel="1"/></span>
@@ -845,7 +846,7 @@
placeholder="Payment Terms"
options="{'no_quick_create':True}"/>
</div>
<field name="delivery_date" attrs="{'invisible': [('show_delivery_date', '=', False)]}"/>
<label for="journal_id"
groups="account.group_account_readonly"
invisible="context.get('default_journal_id') and context.get('move_type', 'entry') != 'entry'"/>
@@ -1207,6 +1208,7 @@
attrs="{'readonly': [('state', '!=', 'draft')]}"/>
<field name="qr_code_method"
attrs="{'invisible': [('display_qr_code', '=', False)]}"/>
<field name="delivery_date"/>
</group>
<group string="Accounting"
name="accounting_info_group"
+4
View File
@@ -74,6 +74,10 @@
<strong>Due Date:</strong>
<p class="m-0" t-field="o.invoice_date_due"/>
</div>
<div t-attf-class="#{'col-auto col-3 mw-100' if report_type != 'html' else 'col'} mb-2" t-if="o.delivery_date" name="delivery_date">
<strong>Delivery Date:</strong>
<p class="m-0" t-field="o.delivery_date"/>
</div>
<div t-attf-class="#{'col-auto col-3 mw-100' if report_type != 'html' else 'col'} mb-2" t-if="o.invoice_origin" name="origin">
<strong>Source:</strong>
<p class="m-0" t-field="o.invoice_origin"/>
+1
View File
@@ -1,2 +1,3 @@
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from . import template_hu
from . import account_move
+22
View File
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, models
class AccountMove(models.Model):
_inherit = 'account.move'
@api.depends('country_code', 'move_type')
def _compute_show_delivery_date(self):
# EXTENDS 'account'
super()._compute_show_delivery_date()
for move in self:
if move.country_code == 'HU':
move.show_delivery_date = move.is_sale_document()
def _post(self, soft=True):
res = super()._post(soft)
for move in self:
if move.country_code == 'HU' and move.is_sale_document() and not move.delivery_date:
move.delivery_date = move.invoice_date
return res
+1
View File
@@ -23,6 +23,7 @@ class AccountChartTemplate(models.AbstractModel):
return {
self.env.company.id: {
'account_fiscal_country_id': 'base.hu',
'tax_calculation_rounding_method': 'round_globally',
'bank_account_code_prefix': '384',
'cash_account_code_prefix': '381',
'transfer_account_code_prefix': '389',
-1
View File
@@ -17,7 +17,6 @@ Odoo Arabic localization for most Saudi Arabia.
'data': [
'data/account_data.xml',
'data/account_tax_report_data.xml',
'views/view_move_form.xml',
'views/report_invoice.xml',
],
'demo': [
+10 -12
View File
@@ -10,17 +10,16 @@ from odoo.tools import float_repr
class AccountMove(models.Model):
_inherit = 'account.move'
l10n_sa_delivery_date = fields.Date(string='Delivery Date', default=fields.Date.context_today, copy=False,
readonly=True, states={'draft': [('readonly', False)]},
help="In case of multiple deliveries, you should take the date of the latest one. ")
l10n_sa_show_delivery_date = fields.Boolean(compute='_compute_show_delivery_date')
l10n_sa_qr_code_str = fields.Char(string='Zatka QR Code', compute='_compute_qr_code_str')
l10n_sa_confirmation_datetime = fields.Datetime(string='Confirmation Date', readonly=True, copy=False)
@api.depends('country_code', 'move_type')
def _compute_show_delivery_date(self):
# EXTENDS 'account'
super()._compute_show_delivery_date()
for move in self:
move.l10n_sa_show_delivery_date = move.country_code == 'SA' and move.move_type in ('out_invoice', 'out_refund')
if move.country_code == 'SA':
move.show_delivery_date = move.is_sale_document()
@api.depends('amount_total_signed', 'amount_tax_signed', 'l10n_sa_confirmation_datetime', 'company_id', 'company_id.vat')
def _compute_qr_code_str(self):
@@ -49,11 +48,10 @@ class AccountMove(models.Model):
def _post(self, soft=True):
res = super()._post(soft)
for record in self:
if record.country_code == 'SA' and record.move_type in ('out_invoice', 'out_refund'):
if not record.l10n_sa_show_delivery_date:
raise UserError(_('Delivery Date cannot be empty'))
self.write({
'l10n_sa_confirmation_datetime': fields.Datetime.now()
})
for move in self:
if move.country_code == 'SA' and move.is_sale_document():
vals = {'l10n_sa_confirmation_datetime': fields.Datetime.now()}
if not move.delivery_date:
vals['delivery_date'] = move.invoice_date
move.write(vals)
return res
+2 -2
View File
@@ -3,14 +3,14 @@
<template id="arabic_english_invoice" inherit_id="l10n_gcc_invoice.arabic_english_invoice">
<xpath expr="//div[@name='due_date']" position="after">
<div class="row" t-if="o.l10n_sa_delivery_date" name="delivery_date">
<div class="row" t-if="o.delivery_date" name="delivery_date">
<div class="col-6"></div>
<div class="col-2">
<strong style="white-space:nowrap">Delivery Date:
</strong>
</div>
<div class="col-2">
<span t-field="o.l10n_sa_delivery_date"/>
<span t-field="o.delivery_date"/>
</div>
<div class="col-2 text-end">
<strong style="white-space:nowrap">:
-15
View File
@@ -1,15 +0,0 @@
<odoo>
<data>
<record id="view_move_form" model="ir.ui.view">
<field name="name">account.move.deliver_date</field>
<field name="model">account.move</field>
<field name="inherit_id" ref="account.view_move_form"/>
<field name="arch" type="xml">
<field name="invoice_date" position="after">
<field name="l10n_sa_show_delivery_date" invisible="1"/>
<field name="l10n_sa_delivery_date" attrs="{'invisible': [('l10n_sa_show_delivery_date', '=', False)], 'required': [('l10n_sa_show_delivery_date', '=', True)]}"/>
</field>
</field>
</record>
</data>
</odoo>
@@ -91,7 +91,7 @@ class AccountEdiXmlUBL21Zatca(models.AbstractModel):
def _get_delivery_vals_list(self, invoice):
""" Override to include/update values specific to ZATCA's UBL 2.1 specs """
shipping_address = invoice.partner_shipping_id
return [{'actual_delivery_date': invoice.l10n_sa_delivery_date,
return [{'actual_delivery_date': invoice.delivery_date or invoice.invoice_date,
'delivery_address_vals': self._get_partner_address_vals(shipping_address) if shipping_address else {},}]
def _get_partner_party_identification_vals_list(self, partner):
+12 -1
View File
@@ -3,7 +3,7 @@
from collections import defaultdict
from odoo import fields, models
from odoo import models, api
from odoo.tools import float_is_zero, float_compare
from odoo.tools.misc import formatLang
@@ -107,6 +107,17 @@ class AccountMove(models.Model):
return res
@api.depends('line_ids.sale_line_ids.order_id')
def _compute_delivery_date(self):
# EXTENDS 'account'
super()._compute_delivery_date()
for move in self:
sale_order_effective_date = list(filter(None, move.line_ids.sale_line_ids.order_id.mapped('effective_date')))
effective_date_res = max(sale_order_effective_date) if sale_order_effective_date else False
# if multiple sale order we take the bigger effective_date
if effective_date_res:
move.delivery_date = effective_date_res
class AccountMoveLine(models.Model):
_inherit = "account.move.line"