mirror of
https://github.com/bringout/oca-ocb-accounting.git
synced 2026-04-19 08:02:01 +02:00
19.0 vanilla
This commit is contained in:
parent
ba20ce7443
commit
768b70e05e
2357 changed files with 1057103 additions and 712486 deletions
|
|
@ -1,4 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from . import account_move
|
||||
from . import account_move
|
||||
from . import account_journal
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class AccountJournal(models.Model):
|
||||
_inherit = "account.journal"
|
||||
|
||||
debit_sequence = fields.Boolean(
|
||||
string="Dedicated Debit Note Sequence",
|
||||
compute="_compute_debit_sequence",
|
||||
readonly=False, store=True,
|
||||
help="Check this box if you don't want to share the same sequence for invoices "
|
||||
"and debit notes made from this journal",
|
||||
)
|
||||
|
||||
@api.depends("type")
|
||||
def _compute_debit_sequence(self):
|
||||
for journal in self:
|
||||
journal.debit_sequence = journal.type in ("sale", "purchase")
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
from odoo import models, fields, api, _
|
||||
|
||||
|
||||
class AccountMove(models.Model):
|
||||
_inherit = "account.move"
|
||||
|
||||
|
|
@ -14,8 +15,8 @@ class AccountMove(models.Model):
|
|||
@api.depends('debit_note_ids')
|
||||
def _compute_debit_count(self):
|
||||
debit_data = self.env['account.move']._read_group([('debit_origin_id', 'in', self.ids)],
|
||||
['debit_origin_id'], ['debit_origin_id'])
|
||||
data_map = {datum['debit_origin_id'][0]: datum['debit_origin_id_count'] for datum in debit_data}
|
||||
['debit_origin_id'], ['__count'])
|
||||
data_map = {debit_origin.id: count for debit_origin, count in debit_data}
|
||||
for inv in self:
|
||||
inv.debit_note_count = data_map.get(inv.id, 0.0)
|
||||
|
||||
|
|
@ -25,10 +26,30 @@ class AccountMove(models.Model):
|
|||
'type': 'ir.actions.act_window',
|
||||
'name': _('Debit Notes'),
|
||||
'res_model': 'account.move',
|
||||
'view_mode': 'tree,form',
|
||||
'view_mode': 'list,form',
|
||||
'domain': [('debit_origin_id', '=', self.id)],
|
||||
}
|
||||
|
||||
def action_debit_note(self):
|
||||
action = self.env.ref('account_debit_note.action_view_account_move_debit')._get_action_dict()
|
||||
return action
|
||||
|
||||
def _get_last_sequence_domain(self, relaxed=False):
|
||||
where_string, param = super()._get_last_sequence_domain(relaxed)
|
||||
if self.journal_id.debit_sequence:
|
||||
where_string += " AND debit_origin_id IS " + ("NOT NULL" if self.debit_origin_id else "NULL")
|
||||
return where_string, param
|
||||
|
||||
def _get_starting_sequence(self):
|
||||
starting_sequence = super()._get_starting_sequence()
|
||||
if (
|
||||
self.journal_id.debit_sequence
|
||||
and self.debit_origin_id
|
||||
and self.move_type in ("in_invoice", "out_invoice")
|
||||
):
|
||||
starting_sequence = "D" + starting_sequence
|
||||
return starting_sequence
|
||||
|
||||
def _get_copy_message_content(self, default):
|
||||
"""Override to handle debit note specific messages."""
|
||||
if default and default.get('debit_origin_id'):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue