feat: add dlv_account_move_copy_ref — copy customer ref on duplicate of customer invoice/credit note, with OK-popup warning
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
from odoo import fields, models
|
||||
|
||||
CUSTOMER_MOVE_TYPES = ("out_invoice", "out_refund")
|
||||
|
||||
|
||||
class AccountMove(models.Model):
|
||||
_inherit = "account.move"
|
||||
|
||||
# Core has copy=False. Flipped to True here; copy_data() below limits the
|
||||
# effect to customer invoices and credit notes.
|
||||
ref = fields.Char(copy=True)
|
||||
|
||||
def copy_data(self, default=None):
|
||||
data_list = super().copy_data(default)
|
||||
if default and "ref" in default:
|
||||
return data_list
|
||||
for move, data in zip(self, data_list):
|
||||
if move.move_type not in CUSTOMER_MOVE_TYPES:
|
||||
data.pop("ref", None)
|
||||
return data_list
|
||||
Reference in New Issue
Block a user