feat(fusion_accounting_documents): Documents app <-> invoice bridge
Replaces Enterprise's documents_account with a Fusion-native bridge. When a PDF/image lands in the Documents app, users can convert it into a draft vendor bill via a wizard that copies the document's binary onto the new account.move and posts a chatter note linking back to the source document. Adds: - documents.document.move_id (Many2one to the linked invoice) - documents.document.is_invoice_candidate (computed; True for unlinked PDF/image binaries) - documents.document.action_create_invoice() opens the wizard - account.move.source_document_ids reverse linkage + statinfo button - fusion.create.invoice.from.document.wizard (TransientModel + form) - ir.actions.server bound to documents.document so the workflow appears in the kanban/list Actions menu (the Documents app has no regular form view to inherit from in v19) The wizard: - defaults to the company's first purchase journal - supports vendor bill or vendor credit note - copies the source attachment onto the new move - posts a chatter note linking back - marks the document linked so it stops appearing as a candidate Auto-installs when documents + fusion_accounting_core are both present. 8 unit tests cover the candidate flag, wizard happy path, attachment copy, reverse linkage, already-linked guard, non-PDF guard, and credit-note creation. Made-with: Cursor
This commit is contained in:
33
fusion_accounting_documents/models/account_move.py
Normal file
33
fusion_accounting_documents/models/account_move.py
Normal file
@@ -0,0 +1,33 @@
|
||||
"""Reverse linkage from account.move back to source documents."""
|
||||
|
||||
from odoo import _, fields, models
|
||||
|
||||
|
||||
class AccountMove(models.Model):
|
||||
_inherit = 'account.move'
|
||||
|
||||
source_document_ids = fields.One2many(
|
||||
'documents.document',
|
||||
'move_id',
|
||||
string='Source Documents',
|
||||
readonly=True,
|
||||
help="Documents in the Documents app that were used to create this move.",
|
||||
)
|
||||
source_document_count = fields.Integer(
|
||||
string='Source Document Count',
|
||||
compute='_compute_source_document_count',
|
||||
)
|
||||
|
||||
def _compute_source_document_count(self):
|
||||
for m in self:
|
||||
m.source_document_count = len(m.source_document_ids)
|
||||
|
||||
def action_open_source_documents(self):
|
||||
self.ensure_one()
|
||||
return {
|
||||
'type': 'ir.actions.act_window',
|
||||
'name': _('Source Documents'),
|
||||
'res_model': 'documents.document',
|
||||
'view_mode': 'kanban,list',
|
||||
'domain': [('move_id', '=', self.id)],
|
||||
}
|
||||
Reference in New Issue
Block a user