[UPD] custom_account_payment: remove receiving method

This commit is contained in:
Samir Ladoui 2025-02-06 18:05:51 +01:00
parent 60d6c51195
commit c927814198
2 changed files with 16 additions and 16 deletions

View File

@ -5,27 +5,27 @@ class AccountPayment(models.Model):
_inherit = 'account.payment' _inherit = 'account.payment'
destination_journal_id = fields.Many2one(comodel_name='account.journal') destination_journal_id = fields.Many2one(comodel_name='account.journal')
available_account_receiving_method_ids = fields.Many2many('account.payment.method.line', compute="_compute_available_account_receiving_method_ids") # available_account_receiving_method_ids = fields.Many2many('account.payment.method.line', compute="_compute_available_account_receiving_method_ids")
account_receiving_method_id = fields.Many2one( # account_receiving_method_id = fields.Many2one(
'account.payment.method.line', # 'account.payment.method.line',
string="Receiving Method", # string="Receiving Method",
default=False # default=False
) # )
paired_internal_transfer_payment_id = fields.Many2one('account.payment', paired_internal_transfer_payment_id = fields.Many2one('account.payment',
help="When an internal transfer is posted, a paired payment is created. " help="When an internal transfer is posted, a paired payment is created. "
"They are cross referenced trough this field", "They are cross referenced trough this field",
copy=False) copy=False)
@api.depends('destination_journal_id') # @api.depends('destination_journal_id')
def _compute_available_account_receiving_method_ids(self): # def _compute_available_account_receiving_method_ids(self):
AccountPaymentMethodLine = self.env['account.payment.method.line'].sudo() # AccountPaymentMethodLine = self.env['account.payment.method.line'].sudo()
for rec in self: # for rec in self:
rec.available_account_receiving_method_ids = AccountPaymentMethodLine.search([('id', 'in', self.destination_journal_id.outbound_payment_method_line_ids.ids)]) # rec.available_account_receiving_method_ids = AccountPaymentMethodLine.search([('id', 'in', self.destination_journal_id.outbound_payment_method_line_ids.ids)])
@api.onchange('destination_journal_id') # @api.onchange('destination_journal_id')
def _onchange_destination_journal_id(self): # def _onchange_destination_journal_id(self):
self.account_receiving_method_id = False # self.account_receiving_method_id = False
def action_post(self): def action_post(self):
res = super(AccountPayment, self).action_post() res = super(AccountPayment, self).action_post()

View File

@ -10,7 +10,7 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="//field[@name='partner_bank_id']" position="after"> <xpath expr="//field[@name='partner_bank_id']" position="after">
<field name="destination_journal_id" domain="[('type','in',('bank','cash'))]" context="{'default_partner_id': partner_id}" attrs="{'invisible': [('is_internal_transfer', '=', False)],'readonly': [('state', '!=', 'draft')], 'required': [('is_internal_transfer', '=', True),('state', '=', 'draft')]}"/> <field name="destination_journal_id" domain="[('type','in',('bank','cash'))]" context="{'default_partner_id': partner_id}" attrs="{'invisible': [('is_internal_transfer', '=', False)],'readonly': [('state', '!=', 'draft')], 'required': [('is_internal_transfer', '=', True),('state', '=', 'draft')]}"/>
<field name="available_account_receiving_method_ids" invisible="1"/> <!-- <field name="available_account_receiving_method_ids" invisible="1"/>
<field <field
name="account_receiving_method_id" name="account_receiving_method_id"
domain="[('id', 'in', available_account_receiving_method_ids)]" domain="[('id', 'in', available_account_receiving_method_ids)]"
@ -18,7 +18,7 @@
'invisible': [('is_internal_transfer', '=', False)], 'invisible': [('is_internal_transfer', '=', False)],
'readonly': [('state', '!=', 'draft')], 'readonly': [('state', '!=', 'draft')],
'required': [('is_internal_transfer', '=', True), ('state', '=', 'draft')] 'required': [('is_internal_transfer', '=', True), ('state', '=', 'draft')]
}" /> }" /> -->
<field name="paired_internal_transfer_payment_id" invisible="1"/> <field name="paired_internal_transfer_payment_id" invisible="1"/>
</xpath> </xpath>