Initial commit: Odoo 18.0-20251222 extra-addons
This commit is contained in:
3
account_invoice_transmit_method/models/__init__.py
Normal file
3
account_invoice_transmit_method/models/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from . import account_move
|
||||
from . import res_partner
|
||||
from . import transmit_method
|
||||
45
account_invoice_transmit_method/models/account_move.py
Normal file
45
account_invoice_transmit_method/models/account_move.py
Normal file
@@ -0,0 +1,45 @@
|
||||
# Copyright 2017-2022 Akretion France (http://www.akretion.com)
|
||||
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class AccountMove(models.Model):
|
||||
_inherit = "account.move"
|
||||
|
||||
transmit_method_id = fields.Many2one(
|
||||
"transmit.method",
|
||||
string="Transmission Method",
|
||||
compute="_compute_transmit_method_id",
|
||||
store=True,
|
||||
readonly=False,
|
||||
tracking=True,
|
||||
ondelete="restrict",
|
||||
domain="""
|
||||
[
|
||||
'|',
|
||||
('customer_ok', '=', invoice_filter_type_domain in (False, 'sale')),
|
||||
('supplier_ok', '=', invoice_filter_type_domain in (False, 'purchase')),
|
||||
]
|
||||
""",
|
||||
)
|
||||
transmit_method_code = fields.Char(
|
||||
string="Transmission Method Code",
|
||||
related="transmit_method_id.code",
|
||||
help="Technical field used for UX purposes",
|
||||
)
|
||||
|
||||
@api.depends("partner_id", "move_type")
|
||||
def _compute_transmit_method_id(self):
|
||||
for rec in self:
|
||||
if rec.partner_id and rec.is_sale_document():
|
||||
rec.transmit_method_id = (
|
||||
rec.partner_id.customer_invoice_transmit_method_id
|
||||
)
|
||||
elif rec.partner_id and rec.is_purchase_document():
|
||||
rec.transmit_method_id = (
|
||||
rec.partner_id.supplier_invoice_transmit_method_id
|
||||
)
|
||||
else:
|
||||
rec.transmit_method_id = False
|
||||
41
account_invoice_transmit_method/models/res_partner.py
Normal file
41
account_invoice_transmit_method/models/res_partner.py
Normal file
@@ -0,0 +1,41 @@
|
||||
# Copyright 2017-2022 Akretion France (http://www.akretion.com)
|
||||
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class ResPartner(models.Model):
|
||||
_inherit = "res.partner"
|
||||
|
||||
customer_invoice_transmit_method_id = fields.Many2one(
|
||||
"transmit.method",
|
||||
string="Customer Invoice Transmission Method",
|
||||
company_dependent=True,
|
||||
tracking=True,
|
||||
ondelete="restrict",
|
||||
domain=[("customer_ok", "=", True)],
|
||||
)
|
||||
customer_invoice_transmit_method_code = fields.Char(
|
||||
related="customer_invoice_transmit_method_id.code",
|
||||
string="Customer Invoice Transmission Method Code",
|
||||
)
|
||||
supplier_invoice_transmit_method_id = fields.Many2one(
|
||||
"transmit.method",
|
||||
string="Vendor Invoice Reception Method",
|
||||
company_dependent=True,
|
||||
tracking=True,
|
||||
ondelete="restrict",
|
||||
domain=[("supplier_ok", "=", True)],
|
||||
)
|
||||
supplier_invoice_transmit_method_code = fields.Char(
|
||||
related="supplier_invoice_transmit_method_id.code",
|
||||
string="Vendor Invoice Reception Method Code",
|
||||
)
|
||||
|
||||
@api.model
|
||||
def _commercial_fields(self):
|
||||
return super()._commercial_fields() + [
|
||||
"customer_invoice_transmit_method_id",
|
||||
"supplier_invoice_transmit_method_id",
|
||||
]
|
||||
26
account_invoice_transmit_method/models/transmit_method.py
Normal file
26
account_invoice_transmit_method/models/transmit_method.py
Normal file
@@ -0,0 +1,26 @@
|
||||
# Copyright 2017-2020 Akretion France (http://www.akretion.com)
|
||||
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class TransmitMethod(models.Model):
|
||||
_name = "transmit.method"
|
||||
_description = "Transmit Method of a document"
|
||||
_order = "sequence, id"
|
||||
|
||||
name = fields.Char(required=True, translate=True)
|
||||
code = fields.Char(
|
||||
copy=False,
|
||||
help="Do not modify the code of an existing Transmit Method "
|
||||
"because it may be used to identify a particular transmit method.",
|
||||
)
|
||||
active = fields.Boolean(default=True)
|
||||
sequence = fields.Integer(default=10)
|
||||
customer_ok = fields.Boolean(string="Selectable on Customers", default=True)
|
||||
supplier_ok = fields.Boolean(string="Selectable on Vendors", default=True)
|
||||
|
||||
_sql_constraints = [
|
||||
("code_unique", "unique(code)", "This transmit method code already exists!")
|
||||
]
|
||||
Reference in New Issue
Block a user