48 lines
1.7 KiB
Python
48 lines
1.7 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Copyright 2026 Nexa Systems Inc.
|
|
# License OPL-1 (Odoo Proprietary License v1.0)
|
|
|
|
from odoo import models, fields, _
|
|
|
|
|
|
class ResPartner(models.Model):
|
|
_inherit = 'res.partner'
|
|
|
|
x_fa_block_email_bill = fields.Boolean(
|
|
string='Block Email Bill Creation',
|
|
default=False,
|
|
help='When enabled, incoming emails from this vendor will NOT '
|
|
'automatically create vendor bills. Use this for vendors '
|
|
'whose bills should be created through Purchase Orders instead.',
|
|
)
|
|
|
|
def action_fa_block_vendors(self):
|
|
"""Block selected vendors from email bill creation."""
|
|
self.write({'x_fa_block_email_bill': True})
|
|
return {
|
|
'type': 'ir.actions.client',
|
|
'tag': 'display_notification',
|
|
'params': {
|
|
'title': _('Vendors Blocked'),
|
|
'message': _('%d vendor(s) blocked from email bill creation.') % len(self),
|
|
'type': 'success',
|
|
'sticky': False,
|
|
'next': {'type': 'ir.actions.act_window_close'},
|
|
}
|
|
}
|
|
|
|
def action_fa_enable_vendors(self):
|
|
"""Enable selected vendors for email bill creation."""
|
|
self.write({'x_fa_block_email_bill': False})
|
|
return {
|
|
'type': 'ir.actions.client',
|
|
'tag': 'display_notification',
|
|
'params': {
|
|
'title': _('Vendors Enabled'),
|
|
'message': _('%d vendor(s) enabled for email bill creation.') % len(self),
|
|
'type': 'success',
|
|
'sticky': False,
|
|
'next': {'type': 'ir.actions.act_window_close'},
|
|
}
|
|
}
|