[FIX] l10n_id_efaktur: add kode_transaksi when generating POS invoice
Current behaviour: When an indonesian customer buys from the POS and generates an invoice, we get an error of missing kode_transaksi of the customer, even tough it it correctly set on the invoice details of the contact. Expected behaviour: Every indonesian contact with correctly setup up invoice details, should be able to checkout from POS and generate an invoice without problems. Steps to reproduce: - Install indonesian accounting localisation, the efaktur module, POS and Contacts - Switch to the Indonesian company - Create a new Contact, add a VAT, check ID PKP, and in Invoicing fill the whole "Indonesian Taxes" section - Add a valid invoice range in the e-fakture general settings - Setup a POS Session if non is present, it's irrelevant, start a new session - Try to buy something with the new contact as customer, and generate a new invoice at checkout. - You should have a pop-up error about the "Kode Transaksi" missing. Reason for the problem: The `l10n_id_kode_transaksi` field is not present in the values used when generating the moves for the invoice. Fix: Add a compute that fetches the kode_transaksi from the partner_id linked to the move. In the meantime, we needed to inverse the readonly states logic (keeping the same behaviour) in order to avoid the compute being triggered in the constraint. Affected versions: - 14.0 - 15.0 - saas-15.2 - saas-15.3 - 16.0 - master opw-2993838 closes odoo/odoo#103457 X-original-commit: cfa43a9ccba225c84972a5d5f9443d9997bd7b31 Signed-off-by: Josse Colpaert <jco@odoo.com> Signed-off-by: Piryns Victor (pivi) <pivi@odoo.com>
This commit is contained in:
committed by
Josse Colpaert
parent
b4f9086bff
commit
55b04db229
@@ -36,14 +36,10 @@ class AccountMove(models.Model):
|
||||
('08', '08 Penyerahan yang PPN-nya Dibebaskan (Impor Barang Tertentu)'),
|
||||
('09', '09 Penyerahan Aktiva ( Pasal 16D UU PPN )'),
|
||||
], string='Kode Transaksi', help='Dua digit pertama nomor pajak',
|
||||
readonly=True, states={'draft': [('readonly', False)]}, copy=False)
|
||||
readonly=False, states={'posted': [('readonly', True)], 'cancel': [('readonly', True)]}, copy=False,
|
||||
compute="_compute_kode_transaksi", store=True)
|
||||
l10n_id_need_kode_transaksi = fields.Boolean(compute='_compute_need_kode_transaksi')
|
||||
|
||||
@api.onchange('partner_id')
|
||||
def _onchange_partner_id(self):
|
||||
self.l10n_id_kode_transaksi = self.partner_id.l10n_id_kode_transaksi
|
||||
return super(AccountMove, self)._onchange_partner_id()
|
||||
|
||||
@api.onchange('l10n_id_tax_number')
|
||||
def _onchange_l10n_id_tax_number(self):
|
||||
for record in self:
|
||||
@@ -55,6 +51,11 @@ class AccountMove(models.Model):
|
||||
for record in self:
|
||||
record.l10n_id_csv_created = bool(record.l10n_id_attachment_id)
|
||||
|
||||
@api.depends('partner_id')
|
||||
def _compute_kode_transaksi(self):
|
||||
for move in self:
|
||||
move.l10n_id_kode_transaksi = move.partner_id.l10n_id_kode_transaksi
|
||||
|
||||
@api.depends('partner_id')
|
||||
def _compute_need_kode_transaksi(self):
|
||||
for move in self:
|
||||
|
||||
Reference in New Issue
Block a user